package com.example.imtoken.modules.main.wallet.details.trade.code

import androidx.lifecycle.MutableLiveData
import com.example.imtoken.core.base.BaseViewModel
import com.example.imtoken.core.utils.Utils
import com.example.imtoken.room.schema.WalletAddressSchema

class ReceivingCodeViewModel : BaseViewModel() {

    private val walletDetailsLiveData = MutableLiveData<WalletAddressSchema>()
    fun setWalletDetailsLiveData(walletAddressSchema: WalletAddressSchema) {
        walletDetailsLiveData.value = walletAddressSchema
    }

    fun getWalletDetailsLiveData(): MutableLiveData<WalletAddressSchema> {
        return walletDetailsLiveData
    }

    /**
     * 创建二维码内容
     * @param a1 String 父级地址
     * @param a2 String 子级地址
     * @param a3 Float  金额
     * @return String
     */
    fun createQRContent(a1: String?, a2: String?, a3: String = "0"): String {
        if (a1 != null && a2 != null) {
            return if (a1 == a2) {
                "ethereum:$a1?decimal=18&value=${Utils.initialAmountMultiply(18, a3)}"
            } else {
                "ethereum:$a1?contractAddress=$a2&decimal=6&value=${
                    Utils.initialAmountMultiply(
                        6,
                        a3
                    )
                }"
            }
        }
        return "error"
    }

}